# encoding: utf-8
from flask import Flask
from apps.cms import blueprint as cms_blueprint
from apps.common import blueprint as common_blueprint
from apps.front import blueprint as front_blueprint
from flask_wtf.csrf import CSRFProtect
from exts import db, mail
import config

csrfProtect = CSRFProtect()

def create_app():
    app = Flask(__name__)
    app.config.from_object(config)

    # 添加蓝图
    app.register_blueprint(cms_blueprint)
    app.register_blueprint(common_blueprint)
    app.register_blueprint(front_blueprint)

    db.init_app(app)
    mail.init_app(app)
    csrfProtect.init_app(app)
    return app

if __name__ == "__main__":
    app = create_app()
    app.run()